<?php

namespace App\Think;

class Redis
{
    public static $instance;
    private $redisPool;

    static function init()
    {
        if(!isset(self::$instance)) self::$instance = new static();
        return self::$instance;
    }

    // public function __construct($opt = []) {
    //     $this->redisPool = \EasySwoole\Pool\Manager::getInstance()->get('redis')->getObj();
    // }

    public function __clone(){}

    public function __call($method, $params) {
        $redisPool = \EasySwoole\RedisPool\Redis::getInstance()->get('redis')->getObj();
        $res = call_user_func_array([$redisPool, $method], $params);   
        \EasySwoole\RedisPool\Redis::getInstance()->get('redis')->recycleObj($redisPool);
        return $res;
    }

}
